// pages/users/invite/index.js
const {
  checkLogin
} = require('../../../utils/util')
const {
  progress,
  getInfo
} = require('../../../api/api')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: ['https://ehsimg.oss-cn-beijing.aliyuncs.com/images/1684482887757.png', 'https://ehsimg.oss-cn-beijing.aliyuncs.com/images/1684482907293.png', 'https://ehsimg.oss-cn-beijing.aliyuncs.com/images/1684482920964.png', 'https://ehsimg.oss-cn-beijing.aliyuncs.com/images/1684482943550.png'],
    level:0,
    id:'',
    info:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    if (options.id) {
      this.setData({
        id:options.id
      })
       this.getInfo()
       this.getProgress()
     }
  },
  
  async getInfo(){
   var {
     result
   } = await getInfo()
   this.setData({
    info:result
   })
  },
 async getProgress(){
   const {id}=this.data
  var {
    result
  } = await progress(id)
  this.setData({
    level:result
  })
 },
 onLoadFunc(){
  this.getProgress()
 },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    // checkLogin().then(async (res) => {
    // }).catch((e) => {
    //   wx.navigateTo({
    //     url: '/pages/login/index',
    //   })
    // })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },
  submit(){
     wx.showModal({
       title: '领取礼品',
       content: '领取礼品请联系客服,是否联系客服',
       confirmText:'联系客服',
       complete: (res) => {
         if (res.confirm) {
            getApp().getCustomerService()
         }
       }
     })
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
    
     return {
       path:'pages/index/index?spreadUserId='+wx.getStorageSync('userInfo').id
     }
 },
})